package beans;

import java.util.ArrayList;
import java.util.List;

import models.Album;
import models.Mail;
import models.Photo;
import models.User;

public class MailBean {
	public String authorName;
	public String url;
	public String content;
	public long time;
	public String MailId;
	public String userId;

	public static MailBean bulid(Mail mail)
	{
		MailBean bean = new MailBean();
		bean.time = mail.createTime;
		bean.MailId = mail.id;
		bean.content = mail.content;
		User user = User.findById(mail.send_id);
		if(user != null)
		{
			bean.authorName = user.nickname;
	        bean.url = user.getPhoto();
            bean.userId=user.id;

		}
		else
		{
			bean.authorName = "";
			bean.url = "";
            bean.userId="";

        }
		return bean;
	}
	
	public static List<MailBean> bulidList(List<Mail> maillist){
		List<MailBean> mailBeanList = new ArrayList<MailBean>();
		for(int item =0 ; item < maillist.size(); item ++){
			Mail mail = maillist.get(item);
			MailBean mailbean = MailBean.bulid(mail);
			mailBeanList.add(mailbean);
		}
		return mailBeanList;
	}
}
